package com.jwsoft.manager.core.gateway.controller;

import com.jwsoft.manager.common.vo.eduClass.EduClassCreateVO;
import com.jwsoft.manager.common.vo.eduClassStudent.EduClassStudentVO;
import com.jwsoft.manager.core.integration.EduClassIntegration;
import com.jwsoft.manager.common.vo.eduClass.EduClassVO;
import com.jwsoft.manager.common.vo.eduClass.EduClassKeyVO;
import com.jwsoft.manager.common.vo.eduClass.EduClassQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

import java.util.List;

/**
 * 分班信息管理网关
 *
 * @author chenzh
 * @since 2023-08-21
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "分班信息管理", description = "分班信息管理")
public class EduClassController {

    @Autowired
    public EduClassIntegration eduClassIntegration;

    @Operation(summary = "分班信息管理分页查询", description = "分班信息管理分页查询")
    @PostMapping(value = "/eduClass0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduClassVO>> getList(@RequestBody @Validated EduClassQueryVO vo) {
        return AppResponse.successData(eduClassIntegration.getList(vo));
    }

    @Operation(summary = "分班信息管理根据主键查询详情", description = "分班信息管理根据主键查询详情")
    @PostMapping(value = "/eduClass0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduClassVO> getById(@RequestBody @Validated EduClassKeyVO vo) {
        return AppResponse.successData(eduClassIntegration.getById(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "分班信息管理新增", description = "分班信息管理新增")
    @PostMapping(value = "/eduClass0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduClassVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduClassVO vo) {
        return AppResponse.successData(eduClassIntegration.add(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "分班信息管理修改", description = "分班信息管理修改")
    @PostMapping(value = "/eduClass0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduClassVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduClassVO vo) {
        return AppResponse.successData(eduClassIntegration.edit(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "分班信息管理删除", description = "分班信息管理删除")
    @PostMapping(value = "/eduClass0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduClassKeyVO vo) {
        eduClassIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "分班信息管理-创建预分班信息", description = "分班信息管理-创建预分班信息")
    @PostMapping(value = "/eduClass0007", produces = "application/json;charset=UTF-8")
    public AppResponse createClass(@RequestBody @Validated EduClassCreateVO vo) {
        eduClassIntegration.createClass(vo);
        return AppResponse.successMsg("预分班成功！");
    }

    @Operation(summary = "分班信息管理-查询是否已分班", description = "分班信息管理-查询是否已分班")
    @PostMapping(value = "/eduClass0008", produces = "application/json;charset=UTF-8")
    public AppResponse<Boolean> getById(@RequestBody @Validated EduClassCreateVO vo) {
        return AppResponse.successData(eduClassIntegration.queryClassFlag(vo));
    }

    @Operation(summary = "分班信息管理-根据学校和年度查询分班信息", description = "分班信息管理-根据学校和年度查询分班信息")
    @PostMapping(value = "/eduClass0009", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduClassVO>> queryByYearAndSchool(@RequestBody @Validated EduClassQueryVO vo) {
        return AppResponse.successData(eduClassIntegration.queryByYearAndSchool(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "分班信息管理-设置班主任和名称", description = "分班信息管理-设置班主任和名称")
    @PostMapping(value = "/eduClass0010", produces = "application/json;charset=UTF-8")
    public AppResponse setAdviser(@RequestBody @Validated EduClassVO vo) {
        eduClassIntegration.setAdviser(vo);
        return AppResponse.successMsg("设置成功！");
    }

    @Operation(summary = "分班信息管理-根据学校和年度查询分班信息", description = "分班信息管理-根据学校和年度查询分班信息")
    @PostMapping(value = "/eduClass0011", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduClassStudentVO>> getStudentByClassId(@RequestBody @Validated EduClassKeyVO vo) {
        return AppResponse.successData(eduClassIntegration.getStudentByClassId(vo));
    }
}
